# -*-coding:utf-8-*-
'''
第1轮： 2,6,3,4,6,8,0   2,3,6,4,6,8,0   2,3,4,6,6,8,0  2,3,4,6,6,8,0  2,3,4,6,6,8,0   2,3,4,6,6,0,8

第2轮：2,3,4,6,6,0,8   2,3,4,6,6,0,8    2,3,4,6,6,0,8  2,3,4,6,6,0,8   2,3,4,6,0,6,8  2,3,4,6,0,6,8

第3轮：2,3,4,6,0,6,8   2,3,4,6,0,6,8   2,3,4,6,0,6,8   2,3,4,0,6,6,8   2,3,4,0,6,6,8   2,3,4,0,6,6,8

第4轮：2,3,4,0,6,6,8   2,3,4,0,6,6,8   2,3,0,4,6,6,8   2,3,0,4,6,6,8   2,3,0,4,6,6,8   2,3,0,4,6,6,8

第5轮：2,3,0,4,6,6,8   2,0,3,4,6,6,8   2,0,3,4,6,6,8   2,0,3,4,6,6,8   2,0,3,4,6,6,8   2,0,3,4,6,6,8

第6轮：2,0,3,4,6,6,8   0,2,3,4,6,6,8   0,2,3,4,6,6,8   0,2,3,4,6,6,8   0,2,3,4,6,6,8   0,2,3,4,6,6,8

'''
def bubbleSort(ilist):
    if len(ilist) <= 1:
        return ilist
    for i in range(1,len(ilist)):
        for j in range(0,len(ilist)-i):
            # 比较相邻两数大小
            if ilist[j] > ilist[j+1]:
                # 将大数排到后面
                ilist[j],ilist[j+1] = ilist[j+1],ilist[j]
        print(f'第{i}轮排序结果：',end='')
        print(ilist)
    return ilist

if __name__ == '__main__':
    ilist = [2,6,3,4,6,8,0]
    print(ilist)
    print(bubbleSort(ilist))

